package com.prs.crm.domain.flow;

import java.util.Set;
import java.util.TreeSet;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import com.prs.crm.domain.BaseEntity;
import com.prs.crm.domain.sys.Form;
/**
 * 流程结点实例化
 * @author Administrator
 *
 */
@Entity
@Table(name="flow_instance")
public  class WorkFlowInstance extends BaseEntity{
	
	
	private static final long serialVersionUID = 3441762084879231604L;
	
	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	private String name;
	@ManyToOne
	private WorkFlow flow;
	
	@ManyToOne
	private WorkFlowType type;
	
	@OneToMany(cascade = CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="instance")
	@OrderBy("sequence asc")
	private Set<WorkFlowInstanceNode> nodes = new TreeSet<WorkFlowInstanceNode>();
	

	
	private Integer state;//启用 禁用  
	
	@ManyToOne
	private Form form;
	
	private String remark;

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getId() {
		return id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setFlow(WorkFlow flow) {
		this.flow = flow;
	}

	public WorkFlow getFlow() {
		return flow;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getRemark() {
		return remark;
	}

	public void setNodes(Set<WorkFlowInstanceNode> nodes) {
		this.nodes = nodes;
	}

	public Set<WorkFlowInstanceNode> getNodes() {
		return nodes;
	}

	public void setState(Integer state) {
		this.state = state;
	}

	public Integer getState() {
		return state;
	}

	public void setForm(Form form) {
		this.form = form;
	}

	public Form getForm() {
		return form;
	}

	public void setType(WorkFlowType type) {
		this.type = type;
	}

	public WorkFlowType getType() {
		return type;
	}

}
